// components/isSignIn/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    noPasswordShow: false,  // 没有设置密码弹窗状态
  },

  /**
   * 组件的方法列表
   */
  methods: {
    async isLogin(){
      wx.cloud.init()
      const {
        data: {
          code,
          errorMsg,
          data
        }
      } = await wx.cloud.callContainer({
        "config": {
          "env": "prod-0g38oh8hf0e4d5ac"
        },
        "path": "/v1/user/login",
        "header": {
          "X-WX-SERVICE": "springboot-069k"
        },
        "method": "get",
        "data": {
          "action": "inc"
        }
      })
      console.log(code,data)
      if (code == 1) {
        if(data.needAuth == 0){ //  有数据 登录成功
          wx.setStorageSync('userInfo', data.userInfo);
          wx.setStorageSync('token', data.userInfo.mobile);
          wx.setStorageSync('openId', data.openId);
        }else{
          this.setData({ noPasswordShow: true })
        }
      } else {
  
      }

      return false
      let that = this
      wx.cloud.callContainer({
        config: {
          env: 'prod-0g38oh8hf0e4d5ac', 
        },
        path: '/v1/user/login', 
        method: 'GET',
        header: {
          'X-WX-SERVICE': 'springboot-u96b', 
        }
      }).then(res => {
      let userInfo = res.data.data.userInfo
        // wx.setStorageSync('openId', res.data.data.openId);
        // wx.setStorageSync('userInfo', userInfo);
        // that.setData({userInfo: userInfo,pageStatus: true})
        console.log(res.data.data.userInfo,res,'看看登录')
      })
    },


    // 关闭
    onNoPasswordClose(){
      this.setData({ noPasswordShow: false })
    },
    // 去登录
    goLogin(){
      wx.navigateTo({
        url: '/pages/my/personalData/index/index',
      })
    },
  }
})
